

alter         trigger tfb_wagefee_bi on tfb_wagefee
instead of insert
as   
begin
  set nocount on
  declare @bid int,@relmonthbid varchar(1000),@sql nvarchar(2000)  
  declare tfb_wagefee_cr cursor local forward_only static optimistic 
  for select distinct bid,relmonthbid from inserted
  open tfb_wagefee_cr
  fetch next from tfb_wagefee_cr into @bid,@relmonthbid
  while @@fetch_status = 0
  begin
    set @sql=N'update tfb_wagemonth set relfeebid='+cast(@bid as varchar)+' where bid in ('+@relmonthbid+')'
    exec sp_executesql @sql
    
    fetch next from tfb_wagefee_cr into @bid,@relmonthbid
  end
  insert into tfb_wagefee select * from inserted  
  close tfb_wagefee_cr
  deallocate tfb_wagefee_cr   
end


















